class RelationsController < ApplicationController
  # GET /relations
  # GET /relations.xml
  def index
    @relations = Relation.find(:all)

    respond_to do |format|
      format.html # index.rhtml
      format.xml  { render :xml => @relations.to_xml }
    end
  end

  # GET /relations/1
  # GET /relations/1.xml
  def show
    @relation = Relation.find(params[:id])

    respond_to do |format|
      format.html # show.rhtml
      format.xml  { render :xml => @relation.to_xml }
    end
  end

  # GET /relations/new
  def new
    @relation = Relation.new
  end

  # GET /relations/1;edit
  def edit
    @relation = Relation.find(params[:id])
  end

  # POST /relations
  # POST /relations.xml
  def create
    @relation = Relation.new(params[:relation])

    respond_to do |format|
      if @relation.save
        flash[:notice] = 'Relation was successfully created.'
        format.html { redirect_to relation_url(@relation) }
        format.xml  { head :created, :location => relation_url(@relation) }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @relation.errors.to_xml }
      end
    end
  end

  # PUT /relations/1
  # PUT /relations/1.xml
  def update
    @relation = Relation.find(params[:id])

    respond_to do |format|
      if @relation.update_attributes(params[:relation])
        flash[:notice] = 'Relation was successfully updated.'
        format.html { redirect_to relation_url(@relation) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @relation.errors.to_xml }
      end
    end
  end

  # DELETE /relations/1
  # DELETE /relations/1.xml
  def destroy
    @relation = Relation.find(params[:id])
    @relation.destroy

    respond_to do |format|
      format.html { redirect_to relations_url }
      format.xml  { head :ok }
    end
  end
end
